package demo10;

public class demo10_1 {
    public static void main(String[] args){
        savaAge(140);
        System.out.println("haha");
        try {
            savaAge2(200);
        } catch (AgeIllegalException e) {
            System.out.println("错误了！！！");
            throw new RuntimeException(e);

        }
    }
    public static void savaAge (int age){
        if (age > 0 && age < 150){
            System.out.println("年龄被成功保存：" + age);
        }
        else {
            throw new AgeIllegalRuntimeException("/ age is illegal, your age is " + age);
        }
    }
    public static void savaAge2(int age) throws AgeIllegalException {
        if (age > 0 && age < 150){
            System.out.println("年龄被成功保存：" + age);
        }
        else {
            throw new AgeIllegalException("/ age is illegal, your age is " + age);
        }
    }
}
